package com.cloud.item;

import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
@SpringBootApplication
//@EnableDiscoveryClient      // 开启服务发现功能
//@EnableEurekaClient         // 开启Eureka客户端
@EnableFeignClients         // 开启Feign客户端
public class ItemApplication {
    public static void main(String[] args) {
        SpringApplication.run(ItemApplication.class);
    }

    @Bean
    @LoadBalanced           // 负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 配置负载均衡器
     *
     * @return
     */
    @Bean
    public RandomRule randomRule() {
        return new RandomRule();
    }
}
